package com.ygsoft.nio.server.filemanager;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SocketChannel;

import org.apache.log4j.Logger;

public class ClientProcessor {
	private Logger log = Logger.getLogger(ClientProcessor.class);
	
	private SocketChannel socketChannel = null;
	private FileWriteWorker writeWorker = null;
	
	private ByteBuffer wBuffer = ByteBuffer.allocate(1024);
	
	public ClientProcessor(SocketChannel socketChannel, FileWriteWorker fileWorker){
		this.socketChannel = socketChannel;
		writeWorker = fileWorker;
	}
	
	public void sendFile(String filePath){
		FileInputStream fis = null;
		
		try {
			fis = new FileInputStream(filePath);
			FileChannel fc = fis.getChannel();
			this.wBuffer.clear();
			int rc = fc.read(this.wBuffer);
			
			log.debug("read file count : " + rc);
			
			byte[] data = this.wBuffer.array();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
}
